package studyguide.ch09.graphics;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;

public class GraphicsCanvasC extends Canvas {

	protected void paint(Graphics g) {
		// Clear screen
		g.setColor(255, 255, 255);
		g.fillRect(0, 0, getWidth(), getHeight());
		
		// Vertical distance between objects:
		int yStep = getHeight() / 3;
		int y = 0;
		int xStep = getWidth() / 3;
		
		g.setColor(0, 0, 0); // Black
		
		y += yStep;
		g.drawString("Triangle:", 0, y, Graphics.TOP|Graphics.LEFT);
		g.setColor(255, 0, 0); // Red
		g.fillTriangle(
				xStep,   y, 
				4*xStep/3, 2*y, 
				2*xStep, 4*y/3);
		
	}

}
